From: Keir Fraser Date: Fri, 10 Dec 2010 16:49:05 +0000 (+0000) Subject: hvm vlapic: Fix tmcct read logic when in periodic mode. X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=d3361c48d3111565596690f638d113e7cf3df198;p=xen.git hvm vlapic: Fix tmcct read logic when in periodic mode. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index cf0ee21081..84dd4d24a5 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -435,12 +435,19 @@ int vlapic_ipi( static uint32_t vlapic_get_tmcct(struct vlapic *vlapic) { struct vcpu *v = current; - uint32_t tmcct, tmict = vlapic_get_reg(vlapic, APIC_TMICT); + uint32_t tmcct = 0, tmict = vlapic_get_reg(vlapic, APIC_TMICT); uint64_t counter_passed; counter_passed = ((hvm_get_guest_time(v) - vlapic->timer_last_update) - / APIC_BUS_CYCLE_NS / vlapic->hw.timer_divisor); - tmcct = (counter_passed < tmict) ? tmict - counter_passed : 0; + / (APIC_BUS_CYCLE_NS * vlapic->hw.timer_divisor)); + + if ( tmict != 0 ) + { + if ( vlapic_lvtt_period(vlapic) ) + counter_passed %= tmict; + if ( counter_passed < tmict ) + tmcct = tmict - counter_passed; + } HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER, "timer initial count %d, timer current count %d, "